package com.yugao.fintech.antelope.auth.oauth2;

import com.yugao.fintech.antelope.auth.oauth2.model.RegisteredClient;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Authentication {
    private RegisteredClient client;

    private String loginId;

    /**
     * 请求的所有参数, 同时也包含业务中额外添加的参数
     */
    @Builder.Default
    private Map<String, Object> additionalParameters = new HashMap<>();

    /**
     * token中的负载信息
     */
    @Builder.Default
    private Map<String, Object> claims = new HashMap<>();

    public RegisteredClient getClient() {
        return client;
    }

    public void setClient(RegisteredClient client) {
        this.client = client;
    }

    public Map<String, Object> getAdditionalParameters() {
        return additionalParameters;
    }

    public void setAdditionalParameters(Map<String, Object> additionalParameters) {
        this.additionalParameters = Collections.unmodifiableMap(
                additionalParameters != null ? new HashMap<>(additionalParameters) : Collections.emptyMap());
        ;
    }

    public String getLoginId() {
        return loginId;
    }

    public void setLoginId(String loginId) {
        this.loginId = loginId;
    }

    public Map<String, Object> getClaims() {
        return claims;
    }

    public void setClaims(Map<String, Object> claims) {
        this.claims = claims;
    }
}
